package com.wontube.smr.remote;

import java.util.List;

import com.wontube.client.modle.vo.PagenateInfo;
import com.wontube.core.annotation.CacheSupport;
import com.wontube.core.annotation.NoLoginSupport;
import com.wontube.core.pub.servlet.handlers.BasicHandler;
import com.wontube.smr.bo.sites.GenreSelectBO;
import com.wontube.smr.client.IAnimeHandler;
import com.wontube.smr.client.model.po.Genre;
import com.wontube.smr.client.model.po.TVEpisode;
import com.wontube.smr.client.model.po.TVShow;
import com.wontube.smr.client.model.vo.EpisodeItems;
import com.wontube.smr.client.model.vo.TVShowItems;
import com.wontube.smr.dao.bo.AnimeSelectDao;
import com.wontube.smr.dao.bo.TVSelectDao;

/**
 * @author tanggf(2012-8-17)
 *
 */
@NoLoginSupport
public class AnimeHandler extends BasicHandler implements IAnimeHandler {	
	@Override
	@CacheSupport(timeToLiveSeconds = 12 * 7 * 3600)
	public List<Genre> selectAnimeGenres() {
		return GenreSelectBO.selectRemendedAnimeGenres();
	}

	@Override
	@CacheSupport
	public TVShowItems searchAnimes(String query, PagenateInfo pageInfo) {
		return AnimeSelectDao.searchAnimes(query, pageInfo);
	}
	
	@Override
	@CacheSupport(timeToLiveSeconds = 2 * 3600)
	public TVShowItems selectPopularAnimes(String genreName,
			PagenateInfo pageInfo) {
		return AnimeSelectDao.selectPopularAnimes(genreName, pageInfo);
	}	

	@Override
	@CacheSupport(timeToLiveSeconds = 2 * 3600)
	public EpisodeItems selectPopularAnimeEpisodes(String genreName,
			PagenateInfo pageInfo) {
		return AnimeSelectDao.selectPopularAnimeEpisodes(genreName, pageInfo);
	}

	@Override
	@CacheSupport
	public EpisodeItems searchAnimeEpisodes(String query, PagenateInfo pageInfo) {
		return AnimeSelectDao.searchAnimeEpisodes(query, pageInfo);
	}

	@Override	
	public TVShowItems selectRecentAnimes(String genreName,
			PagenateInfo pageInfo) {
		return AnimeSelectDao.selectRecentAnimes(genreName, pageInfo);
	}
	
	@Override	
	public TVShowItems selectTopRatedAnimes(String genreName,
			PagenateInfo pageInfo) {
		return AnimeSelectDao.selectTopRatedAnimes(genreName, pageInfo);
	}

	@Override
	@CacheSupport(timeToLiveSeconds = 2 * 3600)
	public TVShowItems selectSimulcastAnimes(String genreName,
			PagenateInfo pageInfo) {
		return AnimeSelectDao.selectSimulcastAnimes(pageInfo);
	}

	@Override
	@CacheSupport(timeToLiveSeconds = 6 * 3600)
	public TVShow getAnimes(String animeId) {
		return TVSelectDao.getTVShow(animeId);
	}

	@Override
	@CacheSupport(timeToLiveSeconds = 6 * 3600)
	public List<Integer> getAllSeasons(String animeId) {
		return TVSelectDao.getAllSeasons(animeId);
	}

	@Override
	@CacheSupport(timeToLiveSeconds = 6 * 3600)
	public List<TVEpisode> getEpisodeList(String animeId, Integer seasonNum) {
		return TVSelectDao.getEpisodeList(animeId, seasonNum);
	}

	@Override
	@CacheSupport(timeToLiveSeconds = 6 * 3600)
	public TVEpisode getAnimeEpisode(String episodeId) {
		return TVSelectDao.getTVEpisode(episodeId);
	}

	@Override
	@CacheSupport(timeToLiveSeconds = 2 * 3600)
	public EpisodeItems selectRecentAnimeEpisodes(String genreName,
			PagenateInfo pageInfo) {
		return AnimeSelectDao.selectRecentAnimeEpisodes(genreName, pageInfo);
	}

	@Override
	@CacheSupport(timeToLiveSeconds = 2 * 3600)
	public EpisodeItems selectTopRatedAnimeEpisodes(String genreName,
			PagenateInfo pageInfo) {
		return AnimeSelectDao.selectTopRatedAnimeEpisodes(genreName, pageInfo);
	}
}
